var range = require('array-range')
function test1() {
	console.log( range(3) );       // -> [ 0, 1, 2 ]
	console.log( range(1, 4) );    // -> [ 1, 2, 3 ]
	// console.log( range(4, 1) ); 

	console.log(range(-10, 10))

	console.log('-----------------------\n')

	console.log( arrayRange(3) ); 
	console.log( arrayRange(1, 4) );
	console.log( arrayRange(1, 4, 2) );
	console.log( arrayRange(5) );
	console.log(arrayRange(-10, 10))

	console.log('-----------------------\n')
}

console.log(range ( 'a' ,  'i' ) )
console.log(arrayRange ( 'a' ,  'i' ) )

console.log(arrayRange(5).map( x => x*x ))
console.log(arrayRange(2, 10).filter( x => x%2===0 ))

console.log('-----------------------\n')
console.log(Array.apply(null, new Array(5)))
console.log((new Array(5)))
console.log((new Array(5)).fill(1))
console.log(arrayRange(5))



/**
 * 返回指定范围的数组 start is inclusive, end is exclusive. 
 * @param  {[type]} start [description]
 * @param  {[type]} end   [description]
 * @param  {Number} step  [description]
 * @return {[type]}       [description]
 */
function arrayRange (start, end, step = 1) {

	if(arguments.length === 1) {
		end = arguments[0]
		start = 0
	}
	start = start | 0
    end = end | 0
	
	var result = []
	while(start < end) {
		result.push(start)
		start += step
	}

	return result
}


/**
 * 建立一个包含指定范围单元的数组
 * 数组
 * @param  {[type]} start [description]
 * @param  {[type]} end   [description]
 * @param  {Number} step  [description]
 * @return {[type]}       [description]
 */
function arrayRangeV0 (start, end, step = 1) {
	if(arguments.length === 1) {
		end = arguments[0]
		start = 0
	}

	var len = end - start
	var result = new Array(len)
	for (var i = 0; i < len; i++, start+= step) {
		result[i] = start
	}
	return result
}